package com.itheima.ydd.mapper;

import com.itheima.ydd.entity.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2022-05-22
 */
@Mapper
public interface SysMenuMapper extends BaseMapper<SysMenu> {


    /**
     * 查询所有菜单
     * @param pid
     * @return
     */
    @Select("select * from sys_menu sm where sm.pid = #{pid}")
    List<SysMenu> selectByPid(int pid);


    @Select("SELECT m.* FROM sys_menu m JOIN sys_role_menu rm ON rm.role_id = #{roleId} AND rm.menu_id = m.id WHERE m.pid = #{id}")
    List<SysMenu> selectMenu(@Param("roleId") String roleId, @Param("id") int id);
}
